<template>
    <div class="mui-numbox" data-numbox-min="1">
        <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
        <input class="mui-input-numbox" type="number" readonly :value="count" ref="num" @change="countChanged">
        <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
    </div>
</template>

<script>
import mui from "../../../static/lib/mui/js/mui.min.js";
export default {
  methods: {
    countChanged() {
      this.$store.commit("modifyGoods", {
        goodsId: this.id,
        count: parseInt(this.$refs.num.value || 1)
      });
    }
  },
  props: ["id", "count"],
  mounted() {
    mui(".mui-numbox").numbox();
  }
};
</script>

<style lang="scss" scoped>
.mui-numbox {
  height: 24px;
}
</style>
